package com.jiangruan.javaApiProject.service;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jiangruan.javaApiProject.Constants;
import com.jiangruan.javaApiProject.bean.bean.DeliciousFood;
import com.jiangruan.javaApiProject.bean.bean.DeliciousFoodCommon;
import com.jiangruan.javaApiProject.net.HttpUtils;

import java.net.URL;
import java.util.List;

/**
 * @Author 默
 * @Date 23:57 2021/12/6
 * @desc
 * @Description
 */
public class DeliciousFoodService {

    public static List<DeliciousFood> getDeliciousFood(){
        String url = Constants.TRIP_URL
                + "?key=" + Constants.TRIP_KEY
                + "&type=food_overall"
                + "&size=0";

        String result = HttpUtils.get(url);
        //对美食达人数据进行JSON
        DeliciousFoodCommon deliciousFoodCommon = JSONObject.parseObject(result, DeliciousFoodCommon.class);

        return deliciousFoodCommon.result;

    }
}
